package br.mikhas.lab.scanner;

public class StringStream implements CharStream {
	private int position = 0;
	private final String string;

	public StringStream(String string) {
		this.string = string;
	}

	@Override
	public int currentPosition() {
		return position;
	}

	@Override
	public String getSection(int start, int end) {
		return string.substring(start, end);
	}

	@Override
	public char nextChar() {
		char c = string.charAt(position);
		position++;
		return c;
	}

	@Override
	public boolean hasNext() {
		return this.position < string.length();
	}

	@Override
	public void setPosition(int pos) {
		this.position = pos;
	}

}
